package com.zt.english.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.zt.english.fragment.word.WordLibPageFragment

class WordLibVpAdapter(val size:Int,fragmentActivity:FragmentActivity): FragmentStateAdapter(fragmentActivity){
    private val fragments = arrayOfNulls<WordLibPageFragment?>(size)
    override fun getItemCount(): Int = size

    override fun createFragment(position: Int): Fragment {
        var fragment = fragments[position]
        if(fragment==null){
            fragment = WordLibPageFragment()
            fragments[position] = fragment
        }
        return fragment
    }
}